package com.guoyan.blockchain.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;


import com.guoyan.blockchain.common.response.BaseResponse;
import com.guoyan.blockchain.service.IMainService;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author yeym
 */
@RestController
public class Operate {
    @Resource
    private IMainService mainService;
    @GetMapping("/test")
    public String test(){
        return "dwdw";
    }

//    @PostMapping("/save/{type}")
//    public BaseResponse save(@RequestBody JSONObject jsonObject,@PathVariable Integer type) {
//        return mainService.save(jsonObject,type);
//    }
//
//    @PostMapping("/save/list/{type}")
//    public BaseResponse saveList(@RequestBody JSONArray jsonArray, @PathVariable Integer type){
//        return mainService.saveList(jsonArray,type);
//    }
    @PostMapping("/save")
    public BaseResponse saveAny(String key,String value){
        System.out.println(key+value);
        return mainService.saveAny(key, value);
    }

    @GetMapping("/query")
    public BaseResponse query(String txId) {
        return mainService.query(txId);
    }

    @GetMapping("/list")
    public BaseResponse getAll(String channelName,Integer count,String startHash) {
        return mainService.getAll(channelName,count,startHash);
    }

    @GetMapping("/query/his")
    public BaseResponse queryHis(String userName) {
        return mainService.queryHis(userName);
    }
}
